#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

int main (int argc, char const* argv[])
{
    int c, n, i, j, ans, m[32768];

    scanf("%d", &c);

    while (c--) {
        scanf("%d", &n);
        memset(m, 0, sizeof(m));
        for (i = 2; i <= n/2; i++) {
            if (n % i == 0) {
                for (j = i; j < n; j+=i) {
                    m[j] = 1;
                }
            }
        }

        ans = 0;
        for (i = 1; i < n; i++) {
            if (!m[i]) {
                ans++;
            }
        }
        printf("%d\n", ans);
    }

    return 0;
}
